package com.xiang.action;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;

@LocalTCC
public interface GoodAction {
    /**
     * 定义两阶段提交 name = 该tcc的bean名称,全局唯一 commitMethod = commit 为二阶段确认方法 rollbackMethod = rollback 为二阶段取消方法
     * useTCCFence=true 为开启防悬挂
     * BusinessActionContextParameter注解 传递参数到二阶段中
     */
    @TwoPhaseBusinessAction(name = "tcc-good", commitMethod = "commit", rollbackMethod = "rollback", useTCCFence = true)
    public boolean tryGood(BusinessActionContext actionContext, @BusinessActionContextParameter(paramName = "goodId") int goodId,
                           @BusinessActionContextParameter(paramName = "num") int num);
    public boolean commit(BusinessActionContext actionContext);
    public boolean rollback(BusinessActionContext actionContext);

}
